struct Solution {}

fn main() {}

impl Solution {
    pub fn find_poisoned_duration(time_series: Vec<i32>, duration: i32) -> i32 {
        let mut total = 0;
        for idx in 1..time_series.len() {
            if (time_series[idx] - time_series[idx - 1]) > duration {
                total += duration;
            }
            else {
                total += time_series[idx] - time_series[idx - 1];
            }
        }
        total + duration
    }
}